
<layout name='../Layout/frame_main' />

<body>


	
	<div class="container-fluid">
		<div class="row-fluid">
			<div class="span12">
				<div class="page-header">
					<h1>
						<?php echo (isset($p)?'修改':'添加');?>产品 
						<small><?php echo (isset($p)?'修改':'新增');?>产品信息</small>
					</h1>
				</div>
			</div>
		</div>
	</div>
	

	<p></p>
	<form action="__URL__/newp/" method="post" >
	<div class="container-fluid">
		<div class="row-fluid">
			<div class="span12">
			<div class="span4">
				<div class="control-group">
		            <select name="type_id" id="type_id" >
                    <option value="0" >请选择大类别</option>
					<volist name="big_type" id="vv">
					<option value="{$vv.type_id}" <eq name="vv.type_id" value="$p.type_id" >selected</eq> >{$vv.type_name}</option>
					</volist>
                    </select>
                    </div>
                    <?php
                    if(isset($p))
                    {
                    	echo '<input type="hidden"  name="pro_id" value="'.$p['pro_id'].'" />';
                    }
                    ?>
					<div class="control-group">
		              <label class="control-label" >商品名称</label>
		              <div class="controls">
		                <input type="text" name="pro_name" value='{$p.pro_name}' >
		                <span class="help-inline"><font class=" text-info"></font></span> </div>
		            </div>

		            <div class="control-group">
		              <label class="control-label" >信息简述</label>
		              <div class="controls">
		                <input type="text" name="pro_detail" value='{$p.pro_detail}' >
		                <span class="help-inline"><font class=" text-info"></font></span> </div>
		            </div>


		            <div class="control-group">
		              <label class="control-label" >进货价格</label>
		              <div class="controls">
		                <input type="text" name="pro_inprice" value='{$p.pro_inprice}' >
		                <span class="help-inline"><font class=" text-info"></font></span> </div>
		            </div>

		            <div class="control-group">
		              <label class="control-label" >库存数量</label>
		              <div class="controls">
		                <input type="text" name="pro_shuliang" value='<?php echo isset($p)?$p['pro_shuliang']:'100'; ?>' >
		                <span class="help-inline"><font class=" text-info"></font></span> </div>
		            </div>
			</div>

			<div class="span8">
			 <div class="span6">

              <div class="suggestionsBox" id="suggestions" style="display: none;">
                <div class="suggestionList" id="autoSuggestionsList"> </div>
              </div>
              <div class="control-group">
                <label class="control-label" ></label>

		            <div class="control-group">
		              <label class="control-label" >上传图片  </label>
		              <div class="controls">
                  <input type="file" id="file1" name="img"  size="30" value="{$p.pro_img}" /><br/>
                  <input type="button" value="上传" class="btn" onclick="return ajaxFileUpload();" />
                   &nbsp;<span id="msg" style="color:blue;font-size:12px;" ></span>
                  <span class="help-inline"><font class=" text-info">为保障图片质量，请上传800*600像素图片</font></span>
		                </div>
		            </div>


                 <div class="control-group">
		              <label class="control-label" >卖出价格</label>
		              <div class="controls">
		                <input type="text" name="pro_selprice" value='{$p.pro_selprice}' >
		                <span class="help-inline"><font class=" text-info"></font></span> </div>
		            </div>

		            <div class="control-group">
		              <label class="control-label" >优惠价</label>
		              <div class="controls">
		                <input type="text" name="pro_batprice" value='{$p.pro_batprice}' >
		                <span class="help-inline"><font class=" text-info"></font></span> </div>
		            </div>


                <input type="hidden"  name="pro_admin"  value="<?php echo $_SESSION[C('USER_AUTH_KEY')]; ?>">
		            <div class="control-group">
		              <div class="controls"><a class="btn btn-success" href="<?php echo U('allp',$rurl);?>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;返回&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
		                <button type="submit" class="btn btn-primary">保存编辑</button>
		              </div>
		            </div>

              </div>
              </div>
              <div class="span6">
                <img id='id_logoimg' src="http://img7.9158.com/200708/10/09/18/200708103758836.jpg"  style="widht:210px;height:210px" />
                <input type="hidden" id="img_URL" name="pro_img" class="span3" value="{$p.pro_img}">
              </div>
			</div>

			</div>
		</div>
	</div>
	</form>

<!--/span-->
</body>



<script type="text/javascript">
// 上传图片
var str = '';
$(function(){
	if($('#img_URL').val()!='')
	{
		$('#id_logoimg').attr('src',"__PUBLIC__/Imgs/Products/m_" + $('#img_URL').val());
	}
});
function ajaxFileUpload(){ 
if($('#file1').val()=="")
  {
    alert("请选择上传文件！");
    return;
  }
  $("#msg").html("正在上传...");

                   
  $.ajaxFileUpload({
    url:'__APP__/Admin/Manage/UploadImg',
    secureuri:false,
    fileElementId:'file1',
    dataType: 'text',
    //data:{name:'qinmi', id:'123'},
    success: function(data){
      if(data=='error'){
        $('#msg').html("<span style='color:red'>上传失败</span>");
      }else{
        $('#msg').html("<span style='color:green'>上传成功</span>");
        str =  data;
        // alert(str);
        $('#img_URL').val(str);
        $('#id_logoimg').attr('src',"__PUBLIC__/Imgs/Products/m_"+str);
      }
    }
  }
);
return false;
}

</script>